<?php
// users (id, name, gender, age)
// 修改和删除 一定要考虑条件。
// 1. update users set gender = 2 where id = 1000;
// 2. update users set gender = 1, age = 30 where id = 2000;
// 3. update users set age = age + 1 where id = 500;
$dsn = 'mysql:host=localhost;dbname=phpcode20;charset=utf8';
$pdo = new PDO($dsn, 'root', '123456');
//$mobile = '13455556666';
//$sql = 'update users set mobile = "' . $mobile . '" where id = 3';
$money = 500;
$sql = 'update users set money = money + ' . $money . ' where id = 2';

$result = $pdo->exec($sql);
var_dump($result);
if ($result === false) {
    echo '修改失败';
} else {
    echo '修改成功';
}
